Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement transactions as a stack and not through revert operations #335

Merged
merged 3 commits into from
Mar 22, 2023

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Mar 22, 2023

Fix #327
Also useful for #166

Instead of implementing transactions by keeping track of what to revert, we now now keep a stack of overlays that are merged into each other.

This also solves a TODO item here we would entirely clear the cache if a transaction is rolled back, which clearly isn't great.

Should be tested by syncing a lot of Polkadot before merging.

@github-actions
Copy link

github-actions bot commented Mar 22, 2023

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       -7065 ┊ smoldot::executor::runtime_host::Inner::run::h49ee950cf6bdd9d9
       +6353 ┊ smoldot::executor::runtime_host::Inner::run::h1ed8dcf557319f04
       -1008 ┊ hashbrown::raw::RawTable<T,A>::reserve_rehash::h11adc6952b61c1ec
        -764 ┊ alloc::collections::btree::remove::<impl alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut,K,V,alloc::collections::btree::node::marker::Leaf>,alloc::collections::btree::node::marker::KV>>::remove_leaf_kv::hfd8f7576f4917697
        -674 ┊ alloc::collections::btree::fix::<impl alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut,K,V,alloc::collections::btree::node::marker::LeafOrInternal>>::fix_node_through_parent::hdd074a3f26afa052
        -656 ┊ alloc::collections::btree::node::BalancingContext<K,V>::bulk_steal_right::h2cc5bb6ccde7d512
        -628 ┊ alloc::collections::btree::node::BalancingContext<K,V>::bulk_steal_left::h3896a78d11cd2662
        -556 ┊ alloc::collections::btree::node::BalancingContext<K,V>::do_merge::h8636792f86c05fa9
        -556 ┊ alloc::collections::btree::node::BalancingContext<K,V>::do_merge::hd32d9638131df306
        -464 ┊ data[0]
        -446 ┊ alloc::collections::btree::remove::<impl alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut,K,V,alloc::collections::btree::node::marker::Internal>,alloc::collections::btree::node::marker::KV>>::remove_internal_kv::hafdac03a9e43d2ee
        -443 ┊ hashbrown::map::HashMap<K,V,S,A>::entry::h011d9f57846129c3
        +419 ┊ <alloc::vec::Vec<T,A> as core::clone::Clone>::clone::h66e7b0c8175da3f8
        -401 ┊ alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut,K,V,alloc::collections::btree::node::marker::LeafOrInternal>::choose_parent_kv::h237b52c4e621120d
        -337 ┊ smoldot::executor::runtime_host::PrefixKeys::inject_keys_ordered::hee9460e0dd9a8a78
        +323 ┊ smoldot::executor::storage_diff::TrieDiff<T>::merge_map::ha824ec590d17814a
        -312 ┊ hashbrown::raw::RawTable<T,A>::find::h36b0039438d9590a
        +297 ┊ smoldot::executor::storage_diff::TrieDiff<T>::diff_get::h08223b1adc67eb0e
        -230 ┊ alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut,K,V,alloc::collections::btree::node::marker::Leaf>,alloc::collections::btree::node::marker::KV>::remove::hc076ea1b7b37e0fb
        -215 ┊ alloc::collections::btree::map::entry::OccupiedEntry<K,V,A>::remove_kv::hbabe7280e207e7e1
       -3176 ┊ ... and 74 more.
      -17260 ┊ Σ [94 Total Rows]

@tomaka
Copy link
Contributor Author

tomaka commented Mar 22, 2023

Synced to block 180k without any problem. The change also seems "obviously correct".

@tomaka tomaka added this pull request to the merge queue Mar 22, 2023
@tomaka tomaka merged commit 4c376f1 into smol-dot:main Mar 22, 2023
@tomaka tomaka deleted the fix-327 branch March 22, 2023 15:58
This was referenced Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EndStorageTransaction is misimplemented when transactions are stacked
1 participant